home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / StdEnv / StdTuple.dcl < prev    next >
Encoding:
Modula Definition  |  1996-12-23  |  1.3 KB  |  34 lines  |  [TEXT/3PRM]

  1. definition module StdTuple
  2.  
  3. // ****************************************************************************************
  4. //    Concurrent Clean Standard Library Module Version 1.1
  5. //    Copyright 1995 University of Nijmegen
  6. // ****************************************************************************************
  7.  
  8. import StdClass
  9.  
  10. instance ==    (a,b)    |    Eq a & Eq b
  11. instance == (a,b,c)    |    Eq a & Eq b & Eq c
  12.  
  13. instance <    (a,b)    |    Ord a & Ord b
  14. instance <    (a,b,c)    |    Ord a & Ord b & Ord c
  15.  
  16. // fst        :: !(!.a,.b) -> .a                                    // t1 of (t1,t2)
  17. fst tuple :== t1 where (t1, _) = tuple
  18. // snd        :: !(.a,!.b) -> .b                                    // t2 of (t1,t2)
  19. snd tuple :== t2 where (_, t2) = tuple
  20.  
  21. // fst3    :: !(!.a,.b,.c) -> .a                                // t1 of (t1,t2,t3)
  22. fst3 tuple :== t1 where (t1, _, _) = tuple
  23. // snd3    :: !(.a,!.b,.c) -> .b                                // t2 of (t1,t2,t3)
  24. snd3 tuple :== t2 where (_, t2, _) = tuple
  25. // thd3    :: !(.a,.b,!.c) -> .c                                // t3 of (t1,t2,t3)
  26. thd3 tuple :== t3 where (_, _, t3) = tuple
  27.  
  28. app2     :: !(.(.a -> .b),.(.c -> .d)) !(.a,.c) -> (.b,.d)    // app2 (f,g) (a,b) = (f a,g b)
  29. app3     :: !(.(.a -> .b),.(.c -> .d),.(.e -> .f)) !(.a,.c,.e) -> (.b,.d,.f)
  30.                                                         // app3 (f,g,h) (a,b,c) = (f a,g b,h c)
  31.  
  32. curry    :: !.((.a,.b) -> .c) .a .b -> .c                // curry f a b    = f (a,b)
  33. uncurry :: !.(.a -> .(.b -> .c)) !(.a,.b) -> .c            // uncurry f (a,b)    = f a b
  34.